/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bbd.crawler.helper;

import java.util.ArrayList;
import java.util.ResourceBundle;

/**
 *
 * @author Amogh
 */
public class InitializeHelper {

    private static final String BUNDLE_BASE_NAME = "crawler";

    private static final String BASE_ARTIST_INFO = "artist.info";
    private static final String BASE_ARTIST_LIST = "artist.list";
    private static final String BASE_MUSIC        = "music";

    //--------------------------------------------------------------------------
    /** Javadoc here */
    public InitializeHelper () { } // end default constructor

    //--------------------------------------------------------------------------
    /** Javadoc here */
    public ArrayList<String> getArtistURLList() {
        return getURLList ( BASE_ARTIST_LIST );
    } // end function getArtistURLList

    //--------------------------------------------------------------------------
    /** Javadoc here */
    public ArrayList<String> getArtistInfoURLList() {
        return getURLList ( BASE_ARTIST_INFO );
    } // end function getArtistInfoURLList

    //--------------------------------------------------------------------------
    /** Javadoc here */
    public ArrayList<String> getSongURLList() {
        return getURLList ( BASE_MUSIC );
    } // end function getSongURLList

    //--------------------------------------------------------------------------
    /** Javadoc here */
    private ArrayList<String> getURLList ( String base ) {

        String countKey = "url." + base + ".count";
        String baseKey  = "url." + base + ".";

        ArrayList<String> urlsList = null;

        ResourceBundle bundle = ResourceBundle.getBundle ( BUNDLE_BASE_NAME );

        if ( bundle != null ) {

            try {

                urlsList = new ArrayList<String>();

                int urlCount = Integer.parseInt ( bundle.getString ( countKey ) );

                for ( int i = 1; i <= urlCount; i++ ) {

                    urlsList.add ( bundle.getString ( baseKey + i ) );
                }
            }
            catch ( Exception ex ) {
                
                urlsList = null;
            }
        }

        return urlsList;

    } // end function getURLList

} // end class InitializeHelper
